package com.gujia.dao;

import com.gujia.model.LoginTicket;
import com.gujia.model.User;
import org.apache.ibatis.annotations.*;

/**
 * Created by GuJia on 2017/6/25.
 */
@Mapper
public interface LoginTicketDao {

    String TABLE_NAME = " login_ticket ";
    String INSERT_FIELDS = " user_id, ticket, expired, status ";
    String SELECT_FIELDS = " id, " + INSERT_FIELDS;

    @Insert({"insert into",TABLE_NAME,"(",INSERT_FIELDS,") values(#{userId},#{ticket},#{expired},#{status})"})
    int addTicket(LoginTicket loginTicket);

    @Delete({"delete from ",TABLE_NAME," where id=#{id}"})
    void deleteById(int id);

    @Select({"select", SELECT_FIELDS," from ",TABLE_NAME," where ticket =#{ticket}"})
    LoginTicket selectByTicket(String name);

    @Update({"update",TABLE_NAME,"set status =#{status} where ticket=#{ticket}"})
    void updatetatus(@Param("ticket") String ticket,@Param("status") String status);
}
